var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/work-flow/util.ts
var util_exports = {};
__export(util_exports, {
  NGLang: () => NGLang,
  cascadeBy: () => cascadeBy,
  commonStyle: () => commonStyle,
  filterUserNodes: () => filterUserNodes,
  getAutoNextFlag: () => getAutoNextFlag,
  getNextTask: () => getNextTask,
  getToolbar: () => getToolbar,
  getUseDynamicType: () => getUseDynamicType,
  openCommonWordList: () => openCommonWordList,
  openNextAppFlowTask: () => openNextAppFlowTask,
  reloadPage: () => reloadPage,
  setNGLang: () => setNGLang,
  setWorkFlowUIState: () => setWorkFlowUIState,
  showFlowInfo: () => showFlowInfo,
  showFlowInfoByPiId: () => showFlowInfoByPiId,
  showPdDiagram: () => showPdDiagram,
  showTaskAttachment: () => showTaskAttachment,
  stringFormat: () => stringFormat,
  wfAlert: () => wfAlert,
  wfConfirm: () => wfConfirm,
  wfMessage: () => wfMessage,
  wfModal: () => wfModal
});
module.exports = __toCommonJS(util_exports);
var import_businessComponent = require("../../businessComponent");
var import_functionalComponent = require("../../functionalComponent");
var import_util = require("../../util");
var NGLang = {
  alertTitle: "提示",
  paramError: "参数不正确！",
  noCallBack: "未传入callback函数，无法执行回调！",
  bizHasRuningProcInst: "单据有正在运行中的流程，不允许送审！",
  bizHasNoFlowInfo: "未找到该单据对应的流程信息",
  getPdListError: "获取流程定义出错",
  ProcessTraceViewTitle: "流程追踪",
  terminateSuccess: "流程终止成功",
  terminateFailure: "流程终止失败",
  diagramViewerTitle: "流程查看",
  taskHisActor: "办理者",
  taskHisMsg: "意见",
  taskHisActorDept: "部门",
  taskHisTime: "办理时间",
  taskHisNode: "节点",
  taskHisTaskDes: "任务",
  taskHisDuration: "停留时间",
  taskHisSignature: "签章",
  attach: "附件",
  focusPoint: "确认事项",
  submitTaskComplete: "正在获取下个任务数据...",
  openNotWebError: "不支持打开非web单据！",
  noDeptData: "未对应部门",
  signatureWinTitle: "签章选择",
  choseSignature: "请选择签章！",
  getSignature: "获取签章数据...",
  hasNoSignature: "未设置签章！",
  getSignatureError: "获取签章数据出错",
  mustSignature: "必需签章！",
  signaturePassword: "签章密码",
  pwd: "密码",
  noPwd: "请输入密码！",
  pwdError: "密码错误",
  perview: "预览",
  btnOk: "确定",
  btnCancel: "取消",
  btnNextTask: "跳过",
  getFlowHisError: "取数流程历史失败",
  btnFeedBack: "流程反馈",
  hasNoNextTask: "当前已是最后一个任务",
  btnFlowDiagram: "流程图",
  btnFlowInfo: "流程信息",
  approvalPoint: "审批要点",
  btnAttach: "流程附件",
  attachCtlInitError: "附件初始化失败",
  btnAbort: "终止",
  btnAddsubtis: "加签",
  btntransmit: "转签",
  btnrollback: "驳回",
  confirmmatter: "确认事项",
  btnSubmit: "提交",
  btnDisagree: "驳回",
  btnAgree: "提交",
  flowInfo: "流程信息",
  showNextNodeInfo: "点击展示后续节点信息",
  myopincommonuse: "我的意见常用语",
  commonPhrases: "常用语",
  emptyRemarkInfo: "请输入办理意见",
  msgTypeSys: "消息自由呼通知",
  msgTypeSMS: "移动消息通知",
  msgContent: "消息",
  msgReceiver: "消息接收人",
  hasNoremark: "请输入办理意见",
  reamrkHasMore: "请至少输入{0}字的意见！",
  hasNoMsgContent: "请输入消息内容",
  hasNoMsgReceiver: "请输入消息接收者",
  taskReassignTo: "任务已转签给:{0}",
  taskReassSuccess: "转签成功",
  taskReassignError: "转签操作失败",
  taskReassignErrorMsg: "参数验证失败。受让人不允许为空",
  whetherTerminate: "是否终止流程",
  addSubTasksSuccess: "加签操作成功",
  addSubTasksFailure: "加签操作失败",
  parentAutoComplete: "加签任务办理后不返回加签人",
  sequential: "按顺序办理",
  getTaskDataInfo: "获取任务办理相关数据...",
  checkApproveFailure: "审批检测失败:",
  getTaskDynamicError: "获取节点动态指派数据出错",
  TaskCompleteSuccess: "任务办理成功",
  TaskCompleteError: "任务办理失败",
  checkCancelApprove: "检测单据是否允许取消审批...",
  canNotCancelApprove: "单据不允许取消审批",
  checkCancelApproveError: "检测是否允许取消审批出错！",
  submitRollBack: "提交驳回操作...",
  rollBackSuccess: "驳回操作成功",
  rollBackError: "驳回操作失败",
  openNextTask: "准备打开下个任务！",
  rollBackNodeWinTitle: "节点选择",
  nodeName: "节点名称",
  nodeId: "节点编码",
  reSetUser: "重新指派人员",
  hasNoRollBakNode: "请选择回退节点",
  rollBackType: "回退方式",
  rollBackPartNodeWinTitle: "请选择需重新办理的节点",
  dynamicBranchWinTitle: "指派下级分支",
  curNodeName: "当前节点",
  nodeMustHasChild: "节点【{0}】必需选择下级分支！",
  nodeMustOnlyOneChild: "节点【{0}】不能选择多个分支！",
  nodeDynamicUsers: "节点人员指派",
  user: "人员",
  notAllNodeSetUser: "不是所有节点都已指派人员",
  userSelectWinTitle: "人员选择",
  userSeachEmptyText: "输入编号/姓名，回车查询",
  flowStartUser: "发起人",
  nextAppName: "下级节点办理人",
  allFlowUser: "所有已办人员",
  treeSeachEmptyText: "输入关键字，定位树节点",
  seachEmptyText: "输入关键字，回车查询",
  userNo: "编号",
  userName: "姓名",
  allUsers: "用户-组织",
  flowUser: "流程人员",
  hasNoSelectData: "未选择数据",
  notFindTreeNode: "没有匹配的树节点",
  createFlowWinTitile: "流程发起",
  flowKeyWord: "流程描述",
  taskRemark: "办理意见",
  procDefin: "流程定义",
  pdId: "编号",
  pdName: "流程名称",
  description: "描述",
  btnView: "查看",
  btnTest: "测试",
  operation: "操作",
  createFlowErrorByNoChildNode: "不存在符合条件的下级分支，不能创建流程实例！",
  createFlow: "创建流程实例",
  startBatchFlow: "发起批量送审",
  startFlowSuccess: "送审成功",
  createFlowSuccess: "流程发起成功",
  createFlowError: "创建流程出错",
  selectOnePd: "请选择流程定义",
  createFlowMinUserCount: "最少指派人数为【{0}】",
  batchStartFlowWinTitile: "批量发起流程",
  batchStartFlowNumberLimit: "批量送审一次性勾选不超过50条",
  selectpsn: "选择人员",
  needReassignNodePersonnel: "是否需要重新进行节点人员指派",
  select: "请选择数据",
  dynamicUsers: "人员指派",
  userId: "主键",
  userDept: "部门",
  userOrg: "组织",
  AddCommonUse: "添加常用",
  DelCommonUse: "删除常用",
  addCommonSuccess: "成功添加常用",
  removeCommonSuccess: "成功删除常用",
  batchStartFlowSuccess: "批量发起流程结果",
  FeedBackTitle: "反馈标题",
  FeedBackReceive: "接收人",
  FeedBackMsg: "反馈信息",
  operatorHelp: "操作员帮助",
  feedbackSubmit: "提交",
  sendSuccess: "发送成功！",
  sendError: "发送失败！",
  selectAddPerson: "加签人员选择",
  selectReassignPerson: "转签人员选择",
  rollBackReason: "驳回原因",
  choseRollBackReason: "请选择驳回原因",
  carbonCopy: "抄送",
  carbonCopyUsersSelect: "选择人员抄送",
  carbonCopyError: "抄送失败",
  carbonCopySuccess: "抄送成功",
  carbonCopySuccessContent: "已抄送给：",
  approvalProgress: "审批进度"
};
function setNGLang(lang) {
  if (lang) {
    import_util.iup.assign(NGLang, import_util.iup.parseJson(lang) || {});
  }
}
var commonStyle = {
  borderStyle: {
    borderRadius: "var(--border-radius-base, 2px)",
    border: "1px solid var(--border-color-base, #f0f0f0)"
  },
  backgroundStyle: {
    backgroundColor: "var(--component-background, #ffffff)"
  }
};
function wfModal(props) {
  return new Promise((resolve) => {
    const { onOk, onCancel, ...others } = props;
    const oldDestroy = (0, import_functionalComponent.showModal)({
      closable: false,
      okText: NGLang.btnOk,
      cancelText: NGLang.btnCancel,
      ...others,
      onOk: async (ins) => {
        ins.destroy = () => {
          resolve(ins.getApi().getOkData ? ins.getApi().getOkData() : true);
          oldDestroy();
        };
        if (onOk) {
          await onOk(ins);
        } else if (ins.getApi().invokeOkHandler) {
          await ins.getApi().invokeOkHandler();
        } else {
          ins.destroy();
        }
      },
      onCancel: async (ins) => {
        ins.destroy = () => {
          resolve(ins.getApi().getCancelData ? ins.getApi().getCancelData() : false);
          oldDestroy();
        };
        if (onCancel) {
          await onCancel(ins);
        } else if (ins.getApi().invokeCancelHandler) {
          await ins.getApi().invokeCancelHandler();
        } else {
          ins.destroy();
        }
      }
    }).destroy;
  });
}
function stringFormat(format, ...args) {
  return format.replace(/\{(\d+)\}/g, function(m, n) {
    return args[n];
  });
}
function filterUserNodes(a, b, key) {
  return b.filter((item) => {
    const targetIds = item[key];
    if (Array.isArray(targetIds)) {
      return targetIds.every((id) => a.includes(id));
    } else {
      return true;
    }
  });
}
function wfAlert(title, content) {
  return new Promise((resolve) => {
    import_functionalComponent.Modal.info({
      title: title || NGLang.alertTitle,
      okText: NGLang.btnOk,
      zIndex: 1001,
      content,
      afterClose: () => {
        resolve("close");
      }
    });
  });
}
function wfConfirm(title, content) {
  return new Promise((resolve) => {
    import_functionalComponent.Modal.confirm({
      title: title || NGLang.alertTitle,
      okText: NGLang.btnOk,
      cancelText: NGLang.btnCancel,
      zIndex: 1001,
      content,
      onOk() {
        resolve(true);
      },
      onCancel() {
        resolve(false);
      }
    });
  });
}
function wfMessage(content, duration = 2) {
  return import_functionalComponent.message.error(content, duration);
}
function reloadPage() {
  console.log("触发当前tab页面刷新");
  import_util.iup.safeRefresh();
}
function getUseDynamicType(hasPsn, dynamicAny) {
  const dynamicType = [];
  if (hasPsn === true) {
    dynamicType.push(1);
    if (dynamicAny === true) {
      dynamicType.push(...[2, 3, 4]);
    }
  } else {
    dynamicType.push(...[2, 3, 4]);
  }
  return dynamicType;
}
function showPdDiagram(row, workInFlow) {
  console.log(row, workInFlow, "");
  const options = {
    microAppName: "workflow",
    AppTitle: NGLang.diagramViewerTitle,
    procInstId: row.id,
    type: "test"
  };
  if (workInFlow.dataId && workInFlow.bizCode) {
    options.AppTitle = "流程测试";
    options.bizKey = workInFlow.dataId;
    options.bizCode = workInFlow.bizCode;
  }
  import_util.iup.open("/flowViewer", options);
}
async function showFlowInfo(bizCode, bizKey) {
  import_util.iup.open("/flowdetail", { microAppName: "workflow", AppTitle: "流程信息", bizKey, bizCode });
}
async function showFlowInfoByPiId(procInstId) {
  import_util.iup.open("/flowdetail", { microAppName: "workflow", AppTitle: "流程信息", procInstId });
}
function openCommonWordList() {
}
function cascadeBy(node, callback) {
  if (callback(node) !== false) {
    node.children && node.children.forEach((nd) => {
      cascadeBy(nd, callback);
    });
  }
}
async function showTaskAttachment(record, status) {
  var _a, _b, _c, _d, _e;
  console.log(record, "record.taskId");
  await (0, import_businessComponent.openAttachment)({
    fileTypeCode: (_e = (_d = (_c = (_b = (_a = import_util.iup.getPageInstance()) == null ? void 0 : _a.getGlobalState) == null ? void 0 : _b.call(_a)) == null ? void 0 : _c.attachmentProperty) == null ? void 0 : _d.wf_file) == null ? void 0 : _e.fileTypeCode,
    permission: { add: status, delete: status },
    asrTable: "flowAttachment",
    asrSessionGuid: record.curSorId ? record.curSorId : ""
  });
}
function getAutoNextFlag() {
  const top = window.top;
  let autoOpenNext = false;
  return autoOpenNext;
}
async function getNextTask({ taskid, catalogGroup }) {
  const close = import_functionalComponent.message.progress({
    title: NGLang.submitTaskComplete
  });
  const data = await import_util.iup.request.get({
    url: "WorkFlow3/WorkFlow/GetNextPendingTaskByUser",
    data: {
      taskid,
      catalogGroup
    }
  });
  close();
  return data;
}
async function openNextAppFlowTask({ nextTaskData, isFromPortal, isTaskList }) {
  let isWeb;
  let url = nextTaskData.url;
  if (!nextTaskData.uitype || nextTaskData.uitype !== 4) {
    isWeb = false;
  } else {
    isWeb = true;
    if (isFromPortal) {
      url += "&isFromProtal=true";
    }
    if (isTaskList) {
      url += "&iswftasklist=true";
    }
  }
}
function getToolbar(toolbar) {
  if (toolbar) {
    const toolbarIns = import_util.iup.isString(toolbar) ? import_util.iup.getCmp(toolbar) : toolbar.current;
    const api = toolbarIns == null ? void 0 : toolbarIns.getApi();
    if (api && api.insert) {
      return api;
    }
  }
  return null;
}
function setWorkFlowUIState(uiInfo, buttonInfo) {
  var _a, _b;
  if (!uiInfo || uiInfo.length === 0)
    return;
  const getProps = (ctlOption) => {
    switch (ctlOption) {
      case "readonly":
        return { disabled: true };
      case "editable":
        return { disabled: false };
      case "hidden":
        return { hidden: true };
      case "required":
        return {
          required: true,
          disabled: false
        };
      default:
        return null;
    }
  };
  import_util.iup.updateUI((updater) => {
    const fieldProps = {};
    uiInfo.forEach((u) => {
      const p = getProps(u.value);
      if (p) {
        u.fieldCode && (fieldProps[`${u.tableName}.${u.fieldCode}`] = p);
        u.propertyCode && (fieldProps[`${u.tableName}.${u.propertyCode}`] = p);
      }
    });
    updater.setFieldProps(fieldProps);
  });
  if (buttonInfo == null ? void 0 : buttonInfo.length) {
    const [disableBtn, hideBtn] = [[], []];
    buttonInfo.forEach(({ rightName, value }) => {
      if (value === "disable") {
        disableBtn.push(rightName);
      }
      if (value === "hidden") {
        hideBtn.push(rightName);
      }
    });
    (_b = (_a = import_util.iup.getPageInstance()).setButtonRights) == null ? void 0 : _b.call(_a, { disableBtn, hideBtn });
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  NGLang,
  cascadeBy,
  commonStyle,
  filterUserNodes,
  getAutoNextFlag,
  getNextTask,
  getToolbar,
  getUseDynamicType,
  openCommonWordList,
  openNextAppFlowTask,
  reloadPage,
  setNGLang,
  setWorkFlowUIState,
  showFlowInfo,
  showFlowInfoByPiId,
  showPdDiagram,
  showTaskAttachment,
  stringFormat,
  wfAlert,
  wfConfirm,
  wfMessage,
  wfModal
});
